package com.twu.biblioteca.Actions;

import com.twu.biblioteca.Interfaces.MenuItems;
import com.twu.biblioteca.Models.Movie;
import com.twu.biblioteca.Models.MovieCollection;

import java.io.IOException;

public class MovieDetailLister implements MenuItems
{
    private MovieCollection movieCollection;

    public MovieDetailLister(MovieCollection movieCollection)
    {
        this.movieCollection = movieCollection;
    }
    @Override
    public void takeAction() throws IOException
    {
        //To change body of implemented methods use File | Settings | File Templates.
        System.out.println("Which Movie details would you like to see?");
        InputReader inputReader = new InputReader();
        String userInput = inputReader.readUserInput();
        Movie movie = movieCollection.returnMovie(userInput);
        if (movie!= null)
        {
            System.out.format("%50s%10s%25s%10s", "Movie Name", "Year","Director Name","Rating");
            System.out.println();
            System.out.format("%50s%10d%25s%10s", movie.getMovieName(),movie.getYear(),movie.getDirectorName(),movie.getRating());
            System.out.println();
        }
        else
        {
            System.out.println("Movie is not in the database!");
        }
    }
}
